package com.example.demo.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
public class Qalibrary {
    private int qaId;
    private String qaQuestion;
    private String qaAnswer;
    private String qaRemind;
    private String qaAuthor;
    private Timestamp qaDate;
    private String qaState;
    private Qatype type;


    @Id
    @Column(name = "QA_ID", nullable = false)
    public int getQaId() {
        return qaId;
    }

    public void setQaId(int qaId) {
        this.qaId = qaId;
    }

    @Basic
    @Column(name = "QA_question", nullable = false, length = 255)
    public String getQaQuestion() {
        return qaQuestion;
    }

    public void setQaQuestion(String qaQuestion) {
        this.qaQuestion = qaQuestion;
    }

    @Basic
    @Column(name = "QA_answer", nullable = false, length = 255)
    public String getQaAnswer() {
        return qaAnswer;
    }

    public void setQaAnswer(String qaAnswer) {
        this.qaAnswer = qaAnswer;
    }

    @Basic
    @Column(name = "QA_remind", nullable = false, length = 255)
    public String getQaRemind() {
        return qaRemind;
    }

    public void setQaRemind(String qaRemind) {
        this.qaRemind = qaRemind;
    }

    @Basic
    @Column(name = "QA_author", nullable = false, length = 20)
    public String getQaAuthor() {
        return qaAuthor;
    }

    public void setQaAuthor(String qaAuthor) {
        this.qaAuthor = qaAuthor;
    }

    @Basic
    @Column(name = "QA_date", nullable = false)
    public Timestamp getQaDate() {
        return qaDate;
    }

    public void setQaDate(Timestamp qaDate) {
        this.qaDate = qaDate;
    }

    @Basic
    @Column(name = "QA_state", nullable = false, length = 100)
    public String getQaState() {
        return qaState;
    }

    public void setQaState(String qaState) {
        this.qaState = qaState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Qalibrary qalibrary = (Qalibrary) o;
        return qaId == qalibrary.qaId &&
                Objects.equals(qaQuestion, qalibrary.qaQuestion) &&
                Objects.equals(qaAnswer, qalibrary.qaAnswer) &&
                Objects.equals(qaRemind, qalibrary.qaRemind) &&
                Objects.equals(qaAuthor, qalibrary.qaAuthor) &&
                Objects.equals(qaDate, qalibrary.qaDate) &&
                Objects.equals(qaState, qalibrary.qaState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(qaId, qaQuestion, qaAnswer, qaRemind, qaAuthor, qaDate, qaState);
    }

    @ManyToOne
    @JoinColumn(name = "QA_typeid", referencedColumnName = "QAT_ID", nullable = false)
    public Qatype getType() {
        return type;
    }

    public void setType(Qatype type) {
        this.type = type;
    }
}
